﻿using System.Windows.Controls;
using PengSW.WindowHelper;

namespace PengSW.TcpService.Ui
{
    /// <summary>
    /// ConnectionManager.xaml 的交互逻辑
    /// </summary>
    public partial class ConnectionManager : UserControl
    {
        public ConnectionManager()
        {
            InitializeComponent();
            DataContext = Connection.AllConnections;
        }

        private void OnRemoveConnection_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            this.Exec(() =>
            {
                Connection aConnection = e.Parameter as Connection;
                aConnection.Dispose();
            });
        }

        private void OnRemoveConnection_CanExecute(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = e.Parameter is Connection;
        }
    }
}
